<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" inline label-width="80px">
      <el-form-item prop="searchValue">
        <el-input
          v-model="queryParams.searchValue"
          placeholder="请输入关键字"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">
          查询
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" border :data="dataList">
      <el-table-column label="用户名" align="center" prop="nickName" />
      <el-table-column label="第三方企业" align="center" prop="corporateName" />
      <el-table-column label="订单摘要" align="center" prop="orderAbstract" />
      <el-table-column label="计费模式" align="center" prop="periodType">
        <template slot-scope="scope">
          <span>{{ scope.row.periodType | ctChargeType }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下单时间" align="center" prop="createTime" />
      <el-table-column label="规格" align="center" prop="marketSkuName" />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listCloudMarket } from "@/api/productManagement/cloudMarket";

export default {
  data() {
    return {
      loading: false, // 遮罩层
      ids: [], // 选中数组
      total: 0, // 总条数
      dataList: [], // 费用中心表格数据
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        searchValue: null, //关键字查询
      },
      //费用类型下拉框数据
      costTypeOptions: [
        { value: "1", label: "信息服务费" },
        { value: "2", label: "CA申领费用" },
      ],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询云市场列表 */
    getList() {
      const data = {
        searchValue: this.queryParams.searchValue,
        params: {
          pageNum: 1,
          pageSize: 10,
        },
      };
      this.loading = true;
      listCloudMarket(this.queryParams)
        .then((res) => {
          this.dataList = res.rows;
          this.total = res.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
